package lec02.pm;

import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;

import eq.util.MyArray;

public class ArraySortDemo {
public static void main(String[] args) {
	int a[]={1,2,3,3,3,12,0,8,};
	Arrays.sort(a);
	MyArray.printArr(a);
	String words[]="one two three four five six seven eight nine ten".split(" ");

	Arrays.sort(words);
	MyArray.printArr(words);
	Arrays.sort(words,Collections.reverseOrder());
	MyArray.printArr(words);
	Arrays.sort(words,new Comparator<String>(){
		@Override
		public int compare(String o1, String o2) {
			// TODO Auto-generated method stub
			//return o2.compareTo(o1);//descend
			//return o2.compareTo(o1);//ascend
			if(o1.length()!=o2.length())
				return o2.length()-o1.length();
			return o1.compareTo(o2);			
		}	
	});
	MyArray.printArr(words);
}
}
